package hk.m4s.lr.repair.test.ui.goods;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import framework.common.baseui.UeBaseActivity;
import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.ClassificationModel;
import hk.m4s.lr.repair.test.model.FlashSaleModel;
import hk.m4s.lr.repair.test.ui.adapter.FlashSaleListAdapter;
import hk.m4s.lr.repair.test.ui.adapter.MenuAdapter;
import hk.m4s.lr.repair.test.views.InnerGridView;
import hk.m4s.lr.repair.test.views.listview.InnerListView;

/**
 * Created by qi.wang on 2017/5/10.
 * 商铺分类
 */

public class ShopClassificationActivity extends UeBaseActivity {
    private ImageView redcommedImg;
    private ListView leftView;
    private ScrollView rightView;
    private InnerListView rightItemView;
   public static List<ClassificationModel> likeList = new ArrayList<>();
   private MenuAdapter menuAdapter;
    private Context context;
    private String goodsId = "";
    private String goodsUrl = "";
    private String makingid;
    private FlashSaleListAdapter adapter;
    private List<FlashSaleModel>flashSaleModelList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        baseSetContentView(R.layout.activity_shop_classification);
        hiddenFooter();
        hiddenHeader();
        context = this;

        findBaseView();

    }

    public void findBaseView() {
        redcommedImg = (ImageView) findViewById(R.id.imgContent);
        leftView = (ListView) findViewById(R.id.leftListView);
        rightView= (ScrollView) findViewById(R.id.rightList);
        rightItemView=(InnerListView) findViewById(R.id.rightItemList);
        menuAdapter=new MenuAdapter(mContext,likeList);
        leftView.setAdapter(menuAdapter);
        leftView.setOnItemClickListener(clickItem);
        adapter=new FlashSaleListAdapter(mContext,flashSaleModelList);
        showInfo();
    }
    public void showInfo(){
        for(int i=0;i<10;i++){
            ClassificationModel model=new ClassificationModel();
            model.setName("推荐分类");
            likeList.add(model);
        }
        menuAdapter.notifyDataSetChanged();
    }

    AdapterView.OnItemClickListener clickItem = new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
            // TODO Auto-generated method stub
            ClassificationModel model = likeList.get(arg2);
            menuAdapter.flag=arg2;
            menuAdapter.notifyDataSetChanged();
//            Intent in = new Intent(ShopRecommedActivity.this, GoodsEventActivity.class);
//            in.putExtra("goods_id", model.getGoodsid());
//            startActivity(in);

        }

    };

//    public void findMakingGoods() {
//        Map<String, Object> parmas = new HashMap<>();
//        parmas.put("device_type", Constant.device_type);
//        parmas.put("userId", SharedPreferencesUtils.getSharedPreferences(Constant.userId, ""));
//        parmas.put("token", SharedPreferencesUtils.getSharedPreferences(Constant.token, ""));
//        parmas.put("makingId", makingid);
//        AccountSerive.findMakingGoods(context, parmas, new ResponseCallback<MakingModel>() {
//            @Override
//            public void onSuccess(MakingModel userinfoModel) {
//                likeList.clear();
//                if (userinfoModel != null) {
//                    if (userinfoModel.getDeepimg() != null) {
//                        Glide.with(context).load(userinfoModel.getDeepimg()).asBitmap().placeholder(R.mipmap.default1).error(R.mipmap.default1).into(redcommedImg);
//                    }
//
//                    if (userinfoModel.getList() != null) {
//                        likeList.addAll(userinfoModel.getList());
//                        carShopLikeAdapter.notifyDataSetChanged();
//                    }
//                }
//            }
//
//            @Override
//            public void onError(Response response, int errorCode, String errorMsg, Exception e) {
//
//            }
//        });
//
//    }
}
